package com.lv.LvTourismForSale.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.aqgj.User.bean.User;
import com.lv.LvPriceComboOfTourismForModify.bean.LvPriceComboOfTourismForModify;
import com.lv.LvPriceComboOfTourismForModify.dao.LvPriceComboOfTourismForModifyDao;
import com.lv.LvPriceComboOfTourismModel.bean.LvPriceComboOfTourismModel;
import com.lv.LvPriceComboOfTourismModel.dao.LvPriceComboOfTourismModelDao;
import com.lv.LvTourismForSale.bean.LvTourismForSale;
import com.lv.LvTourismForSale.dao.LvTourismForSaleDao;
import com.lv.LvTourismModel.bean.LvTourismModel;
import com.lv.LvTourismModel.dao.LvTourismModelDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service("LvTourismForSale")
public class LvTourismForSaleManager {
    @Autowired
    LvTourismForSaleDao lvTourismForSaleDao;
    @Autowired
    LvTourismModelDao lvTourismModelDao;
    @Autowired
    LvPriceComboOfTourismForModifyDao lvPriceComboOfTourismForModifyDao;
    @Autowired
    LvPriceComboOfTourismModelDao lvPriceComboOfTourismModelDao;
    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");

    /**
     * 修改在线旅游
     * @param lvTourismForSale 在线旅游对象
     * @param priceComboData 价格套餐json字符串
     * @param user 用户对象
     * @return
     */
    public String update(LvTourismForSale lvTourismForSale, String priceComboData, User user) {
        Date now=new Date();
        LvTourismForSale lvTourismForSaleBean=lvTourismForSaleDao.get(lvTourismForSale.getId());
        lvTourismForSaleBean.setAdultSeatNumber(lvTourismForSale.getAdultSeatNumber());
        lvTourismForSaleBean.setChildSeatNumber(lvTourismForSale.getChildSeatNumber());
        lvTourismForSaleBean.setAllowIncreaseGuestRoom(lvTourismForSale.getAllowIncreaseGuestRoom());
        if(lvTourismForSale.getAllowIncreaseGuestRoom()==0){
            lvTourismForSaleBean.setGuestRoomPrice(null);
        }else{
            lvTourismForSaleBean.setGuestRoomPrice(lvTourismForSale.getGuestRoomPrice());
        }
        lvTourismForSaleBean.setIsModifyPriceCombo(1);
        lvTourismForSaleBean.setModifyTime(now);
        lvTourismForSaleBean.setFkModifyUserId(user.getId());
        String deleteResult=lvPriceComboOfTourismForModifyDao.delete(null,lvTourismForSaleBean.getFkTourismModelId());
        if("0".equals(deleteResult)){
            return "0";
        }
        BigDecimal minPrice=new BigDecimal(1000000);
        JSONArray priceComboArray= JSON.parseArray(priceComboData);
        for(int i=0;i<priceComboArray.size();i++){
            JSONObject priceCombo=priceComboArray.getJSONObject(i);
            BigDecimal adultPrice=new BigDecimal(priceCombo.getString("adultPrice"));
            if(adultPrice.compareTo(minPrice)<0){
                minPrice=adultPrice;
            }
            LvPriceComboOfTourismForModify lvPriceComboOfTourismForModify=new LvPriceComboOfTourismForModify();
            lvPriceComboOfTourismForModify.setTitle(priceCombo.getString("title"));
            lvPriceComboOfTourismForModify.setSequence(i);
            lvPriceComboOfTourismForModify.setComment(priceCombo.getString("comment"));
            lvPriceComboOfTourismForModify.setAdultPrice(adultPrice);
            lvPriceComboOfTourismForModify.setChildPrice(new BigDecimal(priceCombo.getString("childPrice")));
            lvPriceComboOfTourismForModify.setFkTourismForSaleId(lvTourismForSaleBean.getId());
            lvPriceComboOfTourismForModify.setAddTime(now);
            lvPriceComboOfTourismForModify.setFkAddUserId(user.getId());
            lvPriceComboOfTourismForModifyDao.update(lvPriceComboOfTourismForModify);
        }
        lvTourismForSaleBean.setMinPrice(minPrice);
        String result=lvTourismForSaleDao.update(lvTourismForSaleBean);
        if("0".equals(result)){
            return "0";
        }
        return "1";
    }

    /**
     * 停售在售旅游
     * @param lvTourismForSale 在售旅游对象
     * @return
     */
    public String stopSell(LvTourismForSale lvTourismForSale) {
        String modelId=lvTourismForSale.getFkTourismModelId();
        LvTourismModel lvTourismModel=lvTourismModelDao.get(modelId);
        if(lvTourismModel.getAutoArrangeEndDate()!=null){
            if(lvTourismForSale.getServerDate().getTime()>=lvTourismModel.getAutoArrangeEndDate().getTime()){
                return "overEndDate";
            }
        }
        String result=lvTourismForSaleDao.update(lvTourismForSale);
        if("0".equals(result)){
            return "0";
        }
        return "1";
    }

    /**
     * 获取在售旅游及其价格套餐信息
     * @param id 在售旅游id
     * @return
     */
    public HashMap<String,Object> get(String id) {
        HashMap<String,Object> result=new HashMap<String,Object>();
        LvTourismForSale lvTourismForSale=lvTourismForSaleDao.get(id);
        result.put("lvTourismForSale",lvTourismForSale);
        int count=0;
        if(lvTourismForSale.getIsModifyPriceCombo()==0){
            List<LvPriceComboOfTourismModel> lvPriceComboOfTourismModelList =lvPriceComboOfTourismModelDao.findBy("fkTourismModelId",lvTourismForSale.getFkTourismModelId());
            String priceComboValue = "[";
            for (int i = 0; i < lvPriceComboOfTourismModelList.size(); i++) {
                LvPriceComboOfTourismModel lvPriceComboOfTourismModel = lvPriceComboOfTourismModelList.get(i);
                if(count==lvPriceComboOfTourismModelList.size()){
                    priceComboValue += "{\"title\":\"" + (lvPriceComboOfTourismModel.getTitle() == null ? "" : lvPriceComboOfTourismModel.getTitle())
                            + "\"," + "\"comment\":\"" + (lvPriceComboOfTourismModel.getComment() == null ? "" : lvPriceComboOfTourismModel.getComment())
                            + "\"," + "\"adultPrice\":\"" + (lvPriceComboOfTourismModel.getAdultPrice() == null ? "" : lvPriceComboOfTourismModel.getAdultPrice())
                            + "\"," + "\"childPrice\":\"" + (lvPriceComboOfTourismModel.getChildPrice() == null ? "" : lvPriceComboOfTourismModel.getChildPrice() ) + "\"},";
                }else{
                    priceComboValue += "{\"title\":\"" + (lvPriceComboOfTourismModel.getTitle() == null ? "" : lvPriceComboOfTourismModel.getTitle())
                            + "\"," + "\"comment\":\"" + (lvPriceComboOfTourismModel.getComment() == null ? "" : lvPriceComboOfTourismModel.getComment())
                            + "\"," + "\"adultPrice\":\"" + (lvPriceComboOfTourismModel.getAdultPrice() == null ? "" : lvPriceComboOfTourismModel.getAdultPrice())
                            + "\"," + "\"childPrice\":\"" + (lvPriceComboOfTourismModel.getChildPrice() == null ? "" : lvPriceComboOfTourismModel.getChildPrice() ) + "\"}";
                }
                count++;
            }
            priceComboValue += "]";
            result.put("priceComboData",JSON.parseArray(priceComboValue));
        }else{
            List<LvPriceComboOfTourismForModify> lvPriceComboOfTourismForModifyList =lvPriceComboOfTourismForModifyDao.findBy("fkTourismForSaleId",id);
            String priceComboValue = "[";
            for (int i = 0; i < lvPriceComboOfTourismForModifyList.size(); i++) {
                LvPriceComboOfTourismForModify lvPriceComboOfTourismForModify = lvPriceComboOfTourismForModifyList.get(i);
                if(count==lvPriceComboOfTourismForModifyList.size()){
                    priceComboValue += "{\"title\":\"" + (lvPriceComboOfTourismForModify.getTitle() == null ? "" : lvPriceComboOfTourismForModify.getTitle())
                            + "\"," + "\"comment\":\"" + (lvPriceComboOfTourismForModify.getComment() == null ? "" : lvPriceComboOfTourismForModify.getComment())
                            + "\"," + "\"adultPrice\":\"" + (lvPriceComboOfTourismForModify.getAdultPrice() == null ? "" : lvPriceComboOfTourismForModify.getAdultPrice())
                            + "\"," + "\"childPrice\":\"" + (lvPriceComboOfTourismForModify.getChildPrice() == null ? "" : lvPriceComboOfTourismForModify.getChildPrice() ) + "\"},";
                }else{
                    priceComboValue += "{\"title\":\"" + (lvPriceComboOfTourismForModify.getTitle() == null ? "" : lvPriceComboOfTourismForModify.getTitle())
                            + "\"," + "\"comment\":\"" + (lvPriceComboOfTourismForModify.getComment() == null ? "" : lvPriceComboOfTourismForModify.getComment())
                            + "\"," + "\"adultPrice\":\"" + (lvPriceComboOfTourismForModify.getAdultPrice() == null ? "" : lvPriceComboOfTourismForModify.getAdultPrice())
                            + "\"," + "\"childPrice\":\"" + (lvPriceComboOfTourismForModify.getChildPrice() == null ? "" : lvPriceComboOfTourismForModify.getChildPrice() ) + "\"}";
                }
                count++;
            }
            priceComboValue += "]";
            result.put("priceComboData",JSON.parseArray(priceComboValue));
        }
        return  result;
    }

    /**
     * 获取在售旅游对象
     * @param id 在售旅游id
     * @return
     */
    public LvTourismForSale getById(String id) {
        LvTourismForSale lvTourismForSale=lvTourismForSaleDao.get(id);
        return  lvTourismForSale;
    }

    /**
     * 获取在售旅游列表
     * @param pageNumber 第几页
     * @param pageSize 每页大小
     * @param startSiteName 起始地点名称
     * @param terminalSiteName 结束站点名称
     * @param status 0.在售1.停售2.起草
     * @return
     */
    public List<LvTourismForSale> getList(String pageNumber,String pageSize, String startSiteName, String terminalSiteName,String status) {
        String sql = "select lv_tourism_for_sale.* from lv_tourism_for_sale ,lv_tourism_model where"
                +" lv_tourism_model.id=lv_tourism_for_sale.fk_tourism_model_id"
                +" and lv_tourism_model.status='3'"
                +" and 1=1";
        if (startSiteName != null) {
            sql += " and lv_tourism_model.start_site_name like '%" + startSiteName+ "%'";
        }
        if (terminalSiteName!= null) {
            sql += " and lv_tourism_model.terminal_site_name like '%" + terminalSiteName + "%'";
        }
        if (status!= null) {
            sql += " and lv_tourism_for_sale.status = '" + status + "'";
        }
        sql+=" order by lv_tourism_for_sale.server_date";
        if (pageNumber == null) {
            pageNumber = "0";
        } else {
            int number = Integer.parseInt(pageNumber);
            if (!"0".equals(pageNumber)) {
                number = number - 1;
            }
        }
        List<LvTourismForSale> list=lvTourismForSaleDao.searchWithPage(sql,pageNumber,pageSize);
        for(int i=0;i<list.size();i++){
            LvTourismForSale lvTourismForSale=list.get(i);
            LvTourismModel lvTourismModel=lvTourismModelDao.get(lvTourismForSale.getFkTourismModelId());
            lvTourismForSale.setLvTourismModel(lvTourismModel);
        }
        return  list;
    }

    /**
     * 扫描过期在售旅游并修改其状态
     * @return
     */
    public String  setOverTourismForSale() {
        String sql = "select lv_tourism_for_sale.* from lv_tourism_for_sale ,lv_tourism_model where"
                +" lv_tourism_model.id=lv_tourism_for_sale.fk_tourism_model_id"
                +" and lv_tourism_model.status='3'"
                +" and lv_tourism_for_sale.server_date>CURDATE()"
                +" and lv_tourism_for_sale.status = '0'"
                +" order by lv_tourism_for_sale.server_date";
        List<LvTourismForSale> list=lvTourismForSaleDao.search(sql);
        for(int i=0;i<list.size();i++){
            LvTourismForSale lvTourismForSale=list.get(i);
            lvTourismForSale.setStatus(1);
            String result=lvTourismForSaleDao.update(lvTourismForSale);
            if("0".equals(result)){
                return  result;
            }
        }
        return  "1";
    }

    /**
     * 搜索在售旅游
     * @param modelId 旅游模板id
     * @param startDate 开始日期
     * @param status 状态：0.在售1.停售2.起草
     * @return
     */
    public List<LvTourismForSale> search(String modelId, Date startDate,String status) {
        String sql = "select * from lv_tourism_for_sale where"
                +" lv_tourism_for_sale.fk_tourism_model_id='"+modelId+"'";
        if(startDate!=null){
            sql+=" and lv_tourism_for_sale.server_date>='"+DATE_FORMAT.format(startDate)+"'";
        }
        if(status!=null&&!"".equals(status)){
            sql+=" and lv_tourism_for_sale.status='"+status+"'";
        }
        sql+=" order by lv_tourism_for_sale.server_date";
        List<LvTourismForSale> list=lvTourismForSaleDao.search(sql);
        return list;
    }

    /**
     * 根据日期和旅游模板id获取在售旅游信息
     * @param modelId 模板id
     * @param serverDate 服务日期
     * @return
     */
    public LvTourismForSale searchByDate(String modelId, Date serverDate) {
        String sql = "select * from lv_tourism_for_sale where"
                +" lv_tourism_for_sale.fk_tourism_model_id='"+modelId+"'"
                +" and lv_tourism_for_sale.server_date='"+DATE_FORMAT.format(serverDate)+"'";
        sql+=" order by lv_tourism_for_sale.server_date";
        List<LvTourismForSale> list=lvTourismForSaleDao.search(sql);
        return list.get(0);
    }
    /**
     * 自动排班
     * @return 排班结果信息：0.失败1.成功
     * @throws ParseException
     */
    public String autoArrangeTourism() throws ParseException {
        Date now=new Date();
        String sql = "select * from lv_tourism_model where"
                +" (lv_tourism_model.status='3' or lv_tourism_model.status='4') and lv_tourism_model.scheduling_mode='0'"
                + " order by lv_tourism_model.application_start_date";
        List<LvTourismModel> lvTourismList=lvTourismModelDao.search(sql);
        for(int i=0;i<lvTourismList.size();i++){
            LvTourismModel lvTourismModelBean = lvTourismList.get(i);
            Date autoArrangeEndDate=lvTourismModelBean.getAutoArrangeEndDate();
            if(autoArrangeEndDate!=null&&now.getTime()>=autoArrangeEndDate.getTime()){
                if(lvTourismModelBean.getStatus()==3){
                    lvTourismModelBean.setStatus(4);
                    lvTourismModelDao.update(lvTourismModelBean);
                }
                continue;
            }
            List<LvPriceComboOfTourismModel> priceComboList=lvPriceComboOfTourismModelDao.findBy("fkTourismModelId",lvTourismModelBean.getId());
            BigDecimal minPrice=new BigDecimal(1000000);
            for(int j=0;j<priceComboList.size();j++){
                LvPriceComboOfTourismModel lvPriceComboOfTourismModel=priceComboList.get(j);
                BigDecimal adultPrice=lvPriceComboOfTourismModel.getAdultPrice();
                if(adultPrice.compareTo(minPrice)<0){
                    minPrice=adultPrice;
                }
            }
            sql = "select * from lv_tourism_for_sale where"
                    +" lv_tourism_for_sale.fk_tourism_model_id='"+lvTourismModelBean.getId()+"' and lv_tourism_for_sale.server_date>='"+DATE_FORMAT.format(now)+"'"
                    + " order by lv_tourism_for_sale.server_date";
            List<LvTourismForSale> lvTourismForSaleList = lvTourismForSaleDao.search(sql);
            LvTourismForSale lastLvTourismForSale = lvTourismForSaleList.get(lvTourismForSaleList.size() - 1);
            int index = -1;
            List<Date> serverAllDates = new ArrayList<>();
            Date startDate =now;
            int preSaleDays=lvTourismModelBean.getPreSaleDays();
            if(lvTourismModelBean.getSchedulingRule()==0){
                int intDayFrequencyType = lvTourismModelBean.getSchedulingRuleDay()+1;
                for (int j = 0; j < preSaleDays; j = j + intDayFrequencyType) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(startDate);
                    calendar.add(Calendar.DATE, j);
                    if(lvTourismModelBean.getAutoArrangeEndDate()!=null&&!"".equals(lvTourismModelBean.getAutoArrangeEndDate())){
                        if(calendar.getTime().getTime()<lvTourismModelBean.getAutoArrangeEndDate().getTime()){
                            serverAllDates.add(calendar.getTime());
                        }
                    }else{
                        serverAllDates.add(calendar.getTime());
                    }
                }
            }
            if(lvTourismModelBean.getSchedulingRule()==1){
                String weekDayInfo=lvTourismModelBean.getSchedulingRuleDaysOfWeek();
                String[] weekDays = weekDayInfo.split(",");
                for (int j = 0; j < preSaleDays; j++) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(startDate);
                    calendar.add(Calendar.DATE,j);
                    if(lvTourismModelBean.getAutoArrangeEndDate()!=null&&!"".equals(lvTourismModelBean.getAutoArrangeEndDate())){
                        if(calendar.getTime().getTime()<lvTourismModelBean.getAutoArrangeEndDate().getTime()){
                            for (String day : weekDays) {
                                if (!"".equals(day)) {
                                    if (Integer.parseInt(day) == calendar.get(Calendar.DAY_OF_WEEK) - 1) {
                                        serverAllDates.add(calendar.getTime());
                                    }
                                }
                            }
                        }
                    }else{
                        for (String day : weekDays) {
                            if (!"".equals(day)) {
                                if (Integer.parseInt(day) == calendar.get(Calendar.DAY_OF_WEEK) - 1) {
                                    serverAllDates.add(calendar.getTime());
                                }
                            }
                        }
                    }
                }
            }
            if(lvTourismModelBean.getSchedulingRule()==2) {
                String monthDayInfo = lvTourismModelBean.getSchedulingRuleDaysOfMonth();
                String[] monthDays = monthDayInfo.split(",");
                for (int j = 0; j < preSaleDays; j++) {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(startDate);
                    calendar.add(Calendar.DATE, j);
                    if (lvTourismModelBean.getAutoArrangeEndDate() != null && !"".equals(lvTourismModelBean.getAutoArrangeEndDate())) {
                        if (calendar.getTime().getTime() < lvTourismModelBean.getAutoArrangeEndDate().getTime()) {
                            for (String day : monthDays) {
                                if (!"".equals(day)) {
                                    if (Integer.parseInt(day) == calendar.get(Calendar.DATE)) {
                                        serverAllDates.add(calendar.getTime());
                                    }
                                }
                            }
                        }
                    } else {
                        for (String day : monthDays) {
                            if (!"".equals(day)) {
                                if (Integer.parseInt(day) == calendar.get(Calendar.DATE)) {
                                    serverAllDates.add(calendar.getTime());
                                }
                            }
                        }
                    }
                }
            }
            for (int j= 0; j < serverAllDates.size()-1; j++) {
                Date serverDate = serverAllDates.get(j);
                Date serverDateNext=serverAllDates.get(j+1);
                if (serverDate.getTime()<=lastLvTourismForSale.getServerDate().getTime()&&serverDateNext.getTime()
                        >lastLvTourismForSale.getServerDate().getTime()) {
                    index = j+1;
                    break;
                }else if (serverDateNext.getTime()==lastLvTourismForSale.getServerDate().getTime()) {
                    index = j+2;
                    break;
                }
            }
            if (index != -1) {
                if (index < serverAllDates.size()) {
                   for (int k = index; k < serverAllDates.size(); k++) {
                        Date serverDate = serverAllDates.get(k);
                        if(autoArrangeEndDate.getTime()<=serverDate.getTime()){
                            continue;
                        }
                       LvTourismForSale tourismForSale=new LvTourismForSale();
                       tourismForSale.setAdultSeatNumber(lvTourismModelBean.getAdultSeatNumber());
                       tourismForSale.setChildSeatNumber(lvTourismModelBean.getChildSeatNumber());
                       tourismForSale.setSaledAdultSeatNumber(0);
                       tourismForSale.setSaledChildSeatNumber(0);
                       tourismForSale.setServerDate(serverDate);
                       tourismForSale.setStatus(0);
                       tourismForSale.setMinPrice(minPrice);
                       tourismForSale.setIsModifyPriceCombo(lvTourismModelBean.getAllowIncreaseGuestRoom());
                       tourismForSale.setAddTime(now);
                       tourismForSale.setFkAddUserId(lvTourismModelBean.getFkAddUserId());
                       tourismForSale.setFkTourismModelId(lvTourismModelBean.getId());
                       tourismForSale.setFkTransportId(lvTourismModelBean.getFkTransportId());
                       tourismForSale.setIsModifyPriceCombo(0);
                       lvTourismForSaleDao.update(tourismForSale);
                    }
                }
            }
        }
        return "1";
    }

    /**
     * 起售在售旅游
     * @param id 在售旅游id
     * @param modelId 旅游模板id
     * @param serverDate 服务日期
     * @param userId 用户id
     * @return
     */
    public String restartToSell(String id,String modelId, String serverDate,String userId) {
        LvTourismModel lvTourismModel=lvTourismModelDao.get(modelId);
        if(lvTourismModel.getAutoArrangeEndDate()!=null){
            if(id != null && !"".equals(id)){
                LvTourismForSale lvTourismForSale=lvTourismForSaleDao.get(id);
                if(lvTourismForSale.getServerDate().getTime()>=lvTourismModel.getAutoArrangeEndDate().getTime()){
                    return "overEndDate";
                }
            }else{
                try{
                    Date serverDateBean=DATE_FORMAT.parse(serverDate);
                    if(serverDateBean.getTime()>=lvTourismModel.getAutoArrangeEndDate().getTime()){
                        return "overEndDate";
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
        Date now = new Date();
        if (id != null && !"".equals(id)) {
            LvTourismForSale lvTourismForSale=lvTourismForSaleDao.get(id);
            lvTourismForSale.setStatus(0);
            lvTourismForSale.setFkModifyUserId(userId);
            lvTourismForSale.setModifyTime(now);
            return lvTourismForSaleDao.update(lvTourismForSale);
        } else {
            List<LvPriceComboOfTourismModel> lvPriceComboOfTourismModelList = lvPriceComboOfTourismModelDao.findBy("fkTourismModelId", modelId);
            BigDecimal minPrice = new BigDecimal(1000000);
            for (int i = 0; i < lvPriceComboOfTourismModelList.size(); i++) {
                LvPriceComboOfTourismModel lvPriceComboOfTourismModel = lvPriceComboOfTourismModelList.get(i);
                if (lvPriceComboOfTourismModel.getAdultPrice().compareTo(minPrice) < 0) {
                    minPrice = lvPriceComboOfTourismModel.getAdultPrice();
                }
            }
            LvTourismForSale lvTourismForSale = new LvTourismForSale();
            lvTourismForSale.setAdultSeatNumber(lvTourismModel.getAdultSeatNumber());
            lvTourismForSale.setChildSeatNumber(lvTourismModel.getChildSeatNumber());
            lvTourismForSale.setSaledAdultSeatNumber(0);
            lvTourismForSale.setSaledChildSeatNumber(0);
            try{
                lvTourismForSale.setServerDate(DATE_FORMAT.parse(serverDate));
            }catch (Exception e){
                e.printStackTrace();
            }
            lvTourismForSale.setStatus(0);
            lvTourismForSale.setMinPrice(minPrice);
            lvTourismForSale.setIsModifyPriceCombo(lvTourismModel.getAllowIncreaseGuestRoom());
            lvTourismForSale.setAddTime(now);
            lvTourismForSale.setFkAddUserId(userId);
            lvTourismForSale.setFkTourismModelId(lvTourismModel.getId());
            lvTourismForSale.setAllowIncreaseGuestRoom(lvTourismModel.getAllowIncreaseGuestRoom());
            lvTourismForSale.setGuestRoomPrice(lvTourismModel.getGuestRoomPrice());
            lvTourismForSale.setIsModifyPriceCombo(0);
            return lvTourismForSaleDao.update(lvTourismForSale);
        }
    }

    /**
     * 修改在售旅游
     * @param lvTourismForSale 在售旅游对象
     * @return
     */
    public String update(LvTourismForSale lvTourismForSale) {
        String result=lvTourismForSaleDao.update(lvTourismForSale);
        if("0".equals(result)){
            return "0";
        }
        return "1";
    }
}
